package com.live.video.server;

import com.live.video.mapper.RedPacketRecordMapper;
import com.live.video.model.RedPacketRecord;
import com.live.video.util.MySSDBPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * User: godd
 * Date: 2017-11-14
 * Time: 22:07
 */
@Slf4j
@Service
public class RedPacketRecordServer implements BaseServer<RedPacketRecord> {

    @Autowired
    private RedPacketRecordMapper mapper;

    @Autowired
    @Lazy
    private MySSDBPool ssdbPool;

    private final static String RED_RECORD = "REDPACKET:RECORD:";
    private final static String RED_LIST = "REDPACKET:LIST:";

    @Override
    public void save(RedPacketRecord redPacketRecord) {
        if (redPacketRecord.getId() != null) {
            mapper.updateByPrimaryKeySelective(redPacketRecord);
        } else {
            mapper.insert(redPacketRecord);
        }
    }

    @Override
    public RedPacketRecord queryOne(RedPacketRecord redPacketRecord) {
        return mapper.selectOne(redPacketRecord);
    }

    public List queryAll() {
        return null;
    }

    @Override
    public int remove(RedPacketRecord redPacketRecord) {
        return 0;
    }


    /**
     * 找出当前红包的最佳
     *
     * @author 戴长春    dcc@vtc365.com
     * @date 2017/11/14 22:16
     */
    public void updateBest(Integer redPackedId) {
        //TODO
    }
}
